package greed;
// 打家劫舍
public class leetcode {
    public static void main(String[] args) {
        int[] nums = {1,2,3,1};
        System.out.print(rob(nums));
    }

    public static int rob(int[] nums){
        int m1 = 0;
        int m2 = 0;
        for (int i = 0; i < nums.length; i = i+2) {
            m1 += nums[i];
        }
        for (int i = 1; i < nums.length; i = i+2) {
            m2 += nums[i];
        }

        return Math.max(m1, m2);
    }
}
